using System;
using System.Text;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Presenters;
using System.Text.RegularExpressions;
using Dominio;
using System.IO;

public partial class bugListPage : AbstractView
{
    private BugListPresenter presenter;
    public bugListPage()
    {
        presenter = new BugListPresenter();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (Page.IsPostBack) return;
        this.LogedIn();
        bugTypeDrop.DataSource = Enum.GetNames(typeof(BugTypeEnum));
        bugTypeDrop.DataBind();
        bugTypeDrop.Items.Add("All");
        bugTypeDrop.Items.FindByText("All").Selected = true;
        bugStatusDrop.DataSource = Enum.GetNames(typeof(BugStatusEnum));
        bugStatusDrop.DataBind();
        bugStatusDrop.Items.Add("All");
        bugStatusDrop.Items.FindByText("All").Selected = true;
        bugList.DataSource = presenter.loadBugList();
        bugList.DataBind();

    }

    protected void bugList_RowEditing(object sender, GridViewEditEventArgs e)
    {
        Response.Redirect("BugDetails.aspx?BugId=" + bugList.Rows[e.NewEditIndex].Cells[7].Text + "&statePage=editable");                   
    }

    protected void bugList_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        Response.Redirect("BugDetails.aspx?BugId=" + bugList.Rows[e.NewSelectedIndex].Cells[7].Text + "&statePage=info");
    }
    protected void reloadLik_Click(object sender, EventArgs e)
    {
        bugList.DataSource = presenter.loadFilteredBugList(bugTypeDrop.Text, bugStatusDrop.Text, key.Text);
        bugList.DataBind();
    }
    protected void export_Click(object sender, EventArgs e)
    {
        this.exportToExcel(bugList);
    }
}
